<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=9; IE=8; IE=7; IE=EDGE">
<title>添加驾驶员</title>
<script type="text/javascript" src="../../js/jquery.min.js"></script>
<script type="text/javascript" src="../../js/jquery.pagination.js"></script>
<script type="text/javascript" src="../../js/bootstrap.min.js"></script>
<script type="text/javascript" src="../../js/public.js"></script>
<script type="text/javascript" src="../../js/validata.js"></script>
<script type="text/javascript" src="../../js/alert.js"></script>
<script type="text/javascript" src="../../js/loadSchoolGrade.js"></script>
<script type="text/javascript" src="../../js/jquery-ui/jquery-ui.min.js"></script>
<!-- WdatePicker -->
<script type="text/javascript" src="../../js/My97DatePicker/WdatePicker.js" ></script>
<link rel="stylesheet" type="text/css" href="../../js/jquery-ui/jquery-ui.css">
<link rel="stylesheet" type="text/css" href="../../css/bootstrap.css">
</head>
<body>
	<div class="right_mainH4">
		<p>
			添加驾驶员 <small>Control panel</small>
		</p>
	</div>
	<div>
		<form id="form1">
			<table class="table table-bordered .table-condensed">
				<tr>
					<td>编号:</td>
					<td></td>
					<td>姓名:</td>
					<td>						 
						<input type="text" name="name" class="required"/>
					</td>
					<td rowspan="12" id="image">
						<div class="userface" id="touxiang" onclick="uploadTouxiang();"><span>上传头像</span></div>
						<input type="hidden" name="infopic" class="required"/>
					</td>
				</tr>
				<tr>
					<td>培训机构:</td>
						<td id="schools"></td>
					<td>教龄：</td>
					<td><input type="text" name="teachAge" class="required" /></td>
				</tr>
				<tr>
					<td>政治面貌：</td>
					<td>
						<select name="politicStatus" id="politicStatus" style="width: 90px;">
							<option value="1">群众</option>
							<option value="2">共青团员</option>
							<option value="3">中共党员</option>
							<option value="4">民主党派成员</option>
						</select>
					</td>
					<td>文化程度：</td>
					<td>
						<select name="degree" id="degree" style="width: 90px;">
							<option value="高中">高中</option>
							<option value="文盲">文盲</option>
							<option value="小学">小学</option>
							<option value="初中">初中</option>
							<option value="大专">大专</option>
							<option value="本科">本科</option>
							<option value="硕士">硕士</option>
							<option value="博士">博士</option>
						</select>
					</td>
				</tr>
				<tr>
					<td>性别:</td>
					<td>
						<select name="sex" id="sex" style="width: 90px;">
							<option value="1">男</option>
							<option value="2">女</option>
						</select>
					</td>
					<td>身份证号:</td>
					<td>
						<input type="text" name="idcard" class="required conlength:18" />
					</td>
				</tr>
				<tr>
					<td>手机号:</td>
					<td>
						<input type="text" name="mobile" class="required phone" />
					</td>
					<td>从业资格证有效期:</td>
					<td>
						<input type="text" name="inDate" onClick="WdatePicker();" class="required date"/>
					</td>
				</tr>
				<tr>
					<td>籍贯:</td>
					<td>
						<input type="text" name="nativePlace" class="required maxlength:15"/>
					</td>					
					<td>准教科目:</td>
					<td>
						<!-- 准教科目 zjKeMu -->
						<label><input type="checkbox" id="zjKeMu1" value="2" class="minimal-red" />科目二</label>
						<label><input type="checkbox" id="zjKeMu2" value="3" class="minimal-red" />科目三</label>
						<input type="hidden" name="zjKeMu" class="required"/>
					</td>
				</tr>
				<tr>
					<td>住址:</td>
					<td colspan="3">
						<input type="text" name="address" class="required maxlength:150"/>
					</td>
				</tr>
				<tr>
					<td>入职日期 :</td>
					<td>
						<input type="text" name="hiredate" onClick="WdatePicker();" class="required date"/>
					</td> 
					<td>离职日期 :</td>
					<td>
						<input type="text" name="leavedate" onClick="WdatePicker();" class="date"/>
					</td>
				</tr>
				<tr>
					<td>驾驶证号:</td>
					<td>
						<input type="text" name="drilicence" class="required"/>
					</td>
					<td>驾驶证初领日期:</td>
					<td>
						<input type="text" name="fstdrilicdate" onClick="WdatePicker();" class="required date" />
					</td>
				</tr>
				<tr>
					<td>从业资格证号:</td>
					<td>
						<input type="text" name="occupationno" class="required"/>
					</td>
					<td>职业资格等级:</td>
					<td>
						<select name="occupationlevel" id="occupationlevel" style="width: 90px;">
							<option value="1">一级</option>
							<option value="2">二级 </option>
							<option value="3">三级</option>
							<option value="4">四级</option>
						</select>
					</td>
				</tr>
				<tr>
					<td>准驾车型 :</td>
					<td>
						<select name="dripermitted" id="dripermitted" style="width: 90px;">
							<option value="C1">C1</option>
							<option value="C2">C2</option>
							<option value="A1">A1</option>
							<option value="A2">A2</option>
							<option value="A3">A3</option>
							<option value="B1">B1</option>
							<option value="B2">B2</option>
							<option value="C3">C3</option>
							<option value="C4">C4</option>
							<option value="D">D</option>
							<option value="E">E</option>
							<option value="M">F</option>
							<option value="N">N</option>
							<option value="P">P</option>
						</select>
					</td>
					<td>准教车型 :</td>
					<td>
						<select name="teachpermitted" id="teachpermitted" style="width: 90px;">
							<option value="C1">C1</option>
							<option value="C2">C2 </option>
						</select>
					</td>
				</tr>
				<tr>
					<td>供职状态:</td>
					<td>
						<select name="employstatus" id="employstatus" style="width: 90px;">
							<option value="0">在职</option>
							<option value="1">离职 </option>
						</select>
					</td>
					<td>简介:</td>
					<td>
						<input type="text" name="summary"/>
					</td> 
				</tr>
				<tr>
					<td colspan="5" style="text-align: center;">
						<button type="button" onclick="addDriver();" class="btn btn-info">添加</button>
					</td>
				</tr>
			</table>
		</form>
	</div>
	
     <!-- 上传驾驶员头像 -->
     <div id="uploadImgDiv" style="display:none;" title="头像上传">
     	<iframe src="" style="width:100%;height: 100%" frameborder="no" marginwidth="0" marginheight="0" allowtransparency="yes"></iframe>
     </div>
     
    <script type="text/javascript">
		$(function(){
			var storage = window.sessionStorage;
		    var schools = storage.getItem("schools");//获取存在sessionStorage里的驾校数据
		    if(schools != null){
		    	var schoolHtml;
		    	schoolHtml = '<select name="addDriver.school" id="school" style="width: 160px;"  class="required" onchange="changeSchool();">';
		    	schoolHtml += schools;
		    	schoolHtml += '</select>';
		    	$("#schools").html(schoolHtml);
		    }
		});
		
    	//添加驾驶员信息
    	function addDriver(){
    		var zjKeMu="";
    		$("#form1").find("input[id^='zjKeMu']").each(function(){
    			var check = $(this).prop("checked");
    			if(check == true){
    				zjKeMu += $(this).val()+",";
    			}
    		});
    		zjKeMu = zjKeMu.substr(0,zjKeMu.length-1);
			$("input[name='zjKeMu']").val(zjKeMu);
			
			var infopic = $("input[name='infopic']").val();
			if(!isNull(infopic)){
    			sAlert("请上传照片!");	
    			return;
    		}
			if(validata("form1")){
	    		$.ajax({
	    			url : "../../driver/add.ao",
	    			type : 'POST',
	    			data :$("#form1").serialize(),
	    			cache : false,
	    			beforeSend : ajaxstar,
	    			complete : ajaxend,
	    			dataType : "json",
	    			success : function(data) {
						sAlert(data["result"]);
	    				if(data["state"] == "success"){
	    					clearTable("form1");
	    				}
	    			}
	    		});
			}
    	}
    	
    	//上传驾驶员头像
    	function uploadTouxiang(){
			$("#uploadImgDiv").find("iframe").attr("src","../upload/touxiangUpload.html?case=1");
			$("#uploadImgDiv").dialog({
				title : "头像上传",
				resizable : false,
				width : 850,
				height : 600,
				resizable : true,
				modal : true,
				buttons : {
					"关闭" : function() {
						$(this).dialog("close");
					}
				}
			});
    	}
    	
    	function setImg(path){
    		$("#uploadImgDiv").dialog("close");
    		$("input[name='infopic']").val(path);
    		$("div[class='userface']").html("<img src='" + pickerProjectAdd + path + "' />");
    	}
    </script>
</body>
</html>